﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Server_NhaSach.DataAccess.LogicLayer;
using Server_NhaSach.DataTransferObject;
using System.Data;

namespace Server_NhaSach.BusinessLayer
{
    public class PhieuDieuChinhKhoBlo
    {
                #region "Khai báo các biến"
        private PhieuDieuChinhKhoDAO da;
        private PhieuDieuChinhKhoDTO _pdckho;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public PhieuDieuChinhKhoDTO PDCKho
        {
            get { return _pdckho; }
            set { _pdckho = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public PhieuDieuChinhKhoBlo()
        {
            da = new PhieuDieuChinhKhoDAO();
        }
        public bool InsertPDCKho(string ma, DateTime ngaydc, string manvxuat, string manvnhan, string makhoxuat, string makhonhan, double tongtien)
        {
            _pdckho = new PhieuDieuChinhKhoDTO(ma, ngaydc, manvxuat, manvnhan, makhoxuat, makhonhan, tongtien);
            if (!da.InsertPDCKho(PDCKho))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdatePDCKho(string ma, DateTime ngaydc, string manvxuat, string manvnhan, string makhoxuat, string makhonhan, double tongtien)
        {
            _pdckho = new PhieuDieuChinhKhoDTO(ma, ngaydc, manvxuat, manvnhan, makhoxuat, makhonhan, tongtien);
            if (!da.UpdatePDCKho(PDCKho))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeletePDCKho(string MaPDCK)
        {
            if (!da.DeletePDCKho(MaPDCK))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_PDCKho()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_PDCKho();
            return ds;
        }
        #endregion        
    }
}